package  ybt.demo.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

import  ybt.demo.service.SysUserService;

@Controller
@SessionAttributes(value = { "user" })
public class MainController {
	@Autowired
	private SysUserService userService;

	@RequestMapping(value = { "/", "/login" }, method = RequestMethod.GET)
	public String login() {
		return "login";
	}

	@RequestMapping(value = "/main2")
	public String main2() {
		return "redirect:main";
	}

	@RequestMapping(value = "/main")
	public String main() {
		return "main";
	}

	@RequestMapping(value = "/min2")
	public String stuMain() {
		return "min2";
	}

	 @RequestMapping(value = "/logout") 
	 public String logout(ModelMap modelMap,HttpServletRequest request) {
		 modelMap.remove("user"); 
		 HttpSession session = request.getSession(); 
		 session.removeAttribute("user"); return
	    "redirect:login"; 
		 }
	 
}
